package GUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Flow extends JFrame {
    JLabel label;
    public Flow(String title){
        super(title);
            setLayout(new FlowLayout(FlowLayout.CENTER));
        label = new JLabel("标签");
        getContentPane().add(label);
        JLabel label = new JLabel("标签3");
        getContentPane().add(label);
        JButton button = new JButton("按钮1");
        JButton button1 = new JButton("按钮2");
        getContentPane().add(button);
        getContentPane().add(button1);
        setSize(300,300);
        setVisible(true);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                label.setText("按钮1");
            }
        });
        button1.addActionListener((e)->{
            label.setText("按钮2");
        });
    }
}
